<template>
	<Modal :title="title" v-model="visible" width="920" :footer-hide="true" @on-cancel="visible = false">
		<Card>
			<Row><Table :loading="loading" border :columns="columns" :data="commentData" sortable="custom" ref="table"></Table></Row>
		</Card>
	</Modal>
</template>

<script>
export default {
	name: 'post',
	props: {
		value: {
			type: Boolean,
			default: false
		},
		data: {
			type: Object
		}
	},
	data() {
		return {
			visible: this.value,
			title: '',
			submitLoading: false,
			loading: false,
			maxHeight: 510,
			form: {},
			columns: [
				{
					title: '评论者',
					key: 'userName',
					minWidth: 120
				},
				{
					title: '回复者',
					key: 'replyUserName',
					minWidth: 180
				},
				{
					title: '内容',
					key: 'content',
					minWidth: 180
				},
				{
					title: '评论/回复时间',
					key: 'createTime',
					minWidth: 180
				}
			],
			commentData: []
		};
	},
	methods: {
		setCurrentValue(value) {
			// console.log(this.form)
			if (value === this.visible) {
				return;
			}
			this.title = '查看评论';
			// 回显
			this.form = this.data;
			this.visible = value;

			this.commentData = this.form.commentVos;
			// this.init();
		}
	},
	watch: {
		value(val) {
			this.setCurrentValue(val);
		},
		visible(value) {
			this.$emit('input', value);
		}
	},
	mounted() {
		// this.init();
	}
};
</script>

<style lang="less">
@import '../../../styles/drawer-common.less';
</style>
